<template>
  <div class="summary-outline-wrap">
    <div class="summary-outline-btn">
      <span class="export-btn" v-pdf="{ el: 'item-order-p1', title: '订单概要' }">导出</span>
      <!-- <div class="print" v-print="{ el: `#gf`, popTitle: '项目概要' }">打印</div> -->
    </div>
    <div class="item-order-p1">
      <div class="summary-outline-title">订单概要</div>
      <div id="gf">
        <div class="summary-outline-content">
          <Info :detail="detail" />
          <div class="summary-outline-table mt30">
            <div class="summary-outline-table-title">车型信息</div>
            <Table class="task-table" :data="detail.productCategoryList" :columns="tableDefault.columns"></Table>
          </div>
          <div class="summary-outline-table mt30">
            <div class="summary-outline-table-title">订单进度</div>
            <Table class="task-table" :data="subTask" :columns="taskDefault.columns">
              <template #planStartTime="{ scope }">
                {{ scope.planStartTime ? dayJs(scope.planStartTime).format("YYYY/MM/DD") : "--" }}
              </template>
              <template #planEndTime="{ scope }">
                {{ scope.planEndTime ? dayJs(scope.planEndTime).format("YYYY/MM/DD") : "--" }}
              </template>
              <template #startTime="{ scope }">
                {{ scope.startTime ? dayJs(scope.startTime).format("YYYY/MM/DD") : "--" }}
              </template>
              <template #endTime="{ scope }">
                {{ scope.endTime ? dayJs(scope.endTime).format("YYYY/MM/DD") : "--" }}
              </template>
              <template #status="{ scope }">
                {{ getDictItem("orderStatus", scope.status) }}
              </template>
            </Table>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import { reactive, computed } from "vue";
import Table from "@/components/Table/index.vue";
import { TableProps } from "@/components/Table/interface";
import Info from "./Info.vue";
import { useDict } from "@/hooks/useDict";
import dayJs from "dayjs";
// hook
const { getDictItem } = useDict(["orderStatus"]);
// 变量 const props =
const props = defineProps({
  detail: {
    type: Object,
    default: () => {}
  }
});
const tableDefault: TableProps = reactive({
  data: [],
  columns: [
    {
      type: "index",
      title: "序号",
      key: "name",
      width: 48
    },
    {
      title: "标准车型",
      key: "productCategoryName"
    },
    {
      title: "定制车型",
      key: "name"
    },
    {
      title: "车型数量",
      key: "count",
      width: "0.5fr"
    }
  ],
  // 层级自定义样式
  customContentLayout: [
    {
      layout: 1,
      slotName: ""
    }
  ]
});
const taskDefault: TableProps = reactive({
  data: [],
  columns: [
    {
      type: "index",
      title: "序号",
      key: "name",
      width: 48
    },
    {
      title: "阶段",
      key: "mainTitle"
    },
    {
      title: "阶段分解",
      key: "name"
    },
    {
      title: "计划开始",
      key: "planStartTime"
    },
    {
      title: "计划结束",
      key: "planEndTime"
    },
    {
      title: "实际开始",
      key: "startTime"
    },
    {
      title: "实际结束",
      key: "endTime"
    },
    {
      title: "状态",
      key: "status"
    }
  ],
  // 层级自定义样式
  customContentLayout: [
    {
      layout: 1,
      slotName: ""
    }
  ]
});
// computed
const subTask = computed(() => {
  let subTasks = [];
  props.detail.orderTaskList &&
    props.detail.orderTaskList.forEach(item => {
      item.subtask.forEach((itm: any) => {
        itm.mainTitle = item.name;
        subTasks.push(itm);
      });
    });
  console.log(subTasks);
  return subTasks;
});
</script>
<style lang="scss" scoped>
.summary-outline-wrap {
  box-sizing: border-box;
  min-height: 100%;
  padding: 20px;
  background: #ffffff;
  .summary-outline-btn {
    display: flex;
    justify-content: flex-end;
    font-size: 16px;
    font-weight: 400;
    color: var(--el-color-primary);
    cursor: pointer;
  }
  .summary-outline-title {
    margin-top: 12px;
    margin-bottom: 60px;
    font-size: 26px;
    font-weight: 600;
    color: #333333;
    text-align: center;
  }
  .summary-outline-content {
    margin: 0 $project-padding;
  }
  .summary-outline-table {
    overflow: hidden;
    :deep(.task-table) {
      .wik-table-header {
        background: $project-background;
      }
    }
    &-title {
      margin-bottom: 20px;
      font-size: 16px;
      font-weight: 600;
      color: #333333;
    }
    &-content {
      ul,
      li {
        padding: 0;
        margin: 0;
        list-style: none;
      }
    }
    .table-content-list {
      display: grid;
      grid-template-columns: 1fr 1fr;
      li {
        margin-bottom: 20px;
        font-size: 14px;
        font-weight: 400;
        span:first-child {
          margin-right: 10px;
          color: #666666;
        }
        span:last-child {
          color: #333333;
        }
      }
    }
  }
  .summary-outline-other {
    margin-top: 30px;
  }
}
</style>
